import {store} from "@/store/store.ts";
import ReactDOM from "react-dom/client";
import {Provider} from "react-redux";
import {createBrowserRouter, RouterProvider} from "react-router-dom";
import NotFoundPage from "./404.tsx";
import AdminLayout from "./layout/AdminLayout";
import MainLayout from "./layout/MainLayout/MainLayout.tsx";
import Dashboard from "./pages/Admin/Dashboard";
import ArticleManage from "./pages/Admin/Resource/Article";
import RoleManage from "./pages/Admin/System/RoleManage";
import UserManage from "./pages/Admin/System/UserManage";
import Login from "./pages/Login";

import "./main.css";

const router = createBrowserRouter([
    {
        path: "/",
        element: <MainLayout/>,
        children: [
            {
                path: "/admin/",
                element: <AdminLayout/>,
                children: [
                    {
                        path: "dashboard",
                        element: <Dashboard/>,
                    },
                    {
                        path: "resource",
                        children: [
                            {
                                path: "article",
                                element: <ArticleManage/>
                            }
                        ]
                    },
                    {
                        path: "system",
                        children: [
                            {
                                path: "user",
                                element: <UserManage/>,
                            },
                            {
                                path: "role",
                                element: <RoleManage/>,
                            }
                        ]
                    },
                ],
            },
            {
                path: "/login",
                element: <Login/>,
            },
        ],
    },

    {
        path: "*",
        element: <NotFoundPage/>, // 404 路由
    },
]);

ReactDOM.createRoot(document.getElementById("root")!).render(
    <Provider store={store}><RouterProvider router={router}/></Provider>,
);

